<?php
	//
	//This php will handle the 
	// UserFetch.java 
	// - fetchUserById function
	//
	
	//Connect to database
	include '../../dbc.php';
	
	//$id = $_POST['id'];
	
	//Select non-admin and non-blocked restaurant
    $query01 = "SELECT * FROM restaurant WHERE is_admin='0' AND is_blocked='0' ORDER BY name ASC";
	$query01_result = mysql_query($query01);
	if(mysql_num_rows($query01_result) > 0){
		$i = 0;
		while($query01_result_row = mysql_fetch_array($query01_result)){
			$id[$i] = $query01_result_row['id'];
			$name[$i] = $query01_result_row['name'];
			$address[$i] = $query01_result_row['address'];
			$telephone[$i] = $query01_result_row['telephone'];
			$open_hours[$i] = $query01_result_row['open_hours'];
			$description[$i] = $query01_result_row['description'];
			$profile_picture[$i] = $query01_result_row['profile_picture'];
			$tag[$i] = $query01_result_row['tag'];
			$coupon[$i] = $query01_result_row['coupon'];
			$i++;
		}
		
		
		$response["STATUS"] = "1";
		$response["NUMBER"] = $i;
		$response["ID"] = $id;
		$response["NAME"] = $name;
		$response["ADDRESS"] = $address;
		$response["TELEPHONE"] = $telephone;
		$response["OPEN_HOURS"] = $open_hours;
		$response["DESCRIPTION"] = $description;
		$response["PROFILE_PICTURE"] = $profile_picture;
		$response["TAG"] = $tag;
		$response["COUPON"] = $coupon;
		
		echo json_encode($response);
	}else{
		//Unable to get user
		$response["STATUS"] = "0";
		$response["NUMBER"] = "0";
		echo json_encode($response);
	}
	

?>